package com.kevin.iterator.impl;

import com.kevin.iterator.Aggregate;
import com.kevin.iterator.Iterator;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * 具体聚合
 *
 * @author kevin
 * @date 2025/8/12
 */
public class ConcreteAggregate implements Aggregate {

    private List<Object> list = new ArrayList<>();

    @Override
    public void add(Object obj) {
        list.add(obj);
    }

    @Override
    public void remove(Object obj) {
        list.remove(obj);
    }

    @Override
    public Iterator getIterator() {
        return new ConcreteIterator(list);
    }
}
